package com.young.shop_admin.services.impl;

import com.young.shop_admin.dao.SellerDao;
import com.young.shop_admin.dao.impl.SellerDaoImpl;
import com.young.shop_admin.pojo.entity.Seller;
import com.young.shop_admin.services.SellerService;

public class SellerServiceImpl implements SellerService {
    private SellerDao sellerDao = new SellerDaoImpl();

    @Override
    public Seller checkSellerLogin(Seller seller) {
        String userName = seller.getUserName();
        //通过用户名查询数据库，用户是否存在
        Seller dbSeller = sellerDao.getSellerByUserName(userName);
        if (dbSeller == null ) {
            //用户不存在
            throw new RuntimeException("用户不存在");
        }
        //判断密码是否正确
        if (!dbSeller.getPassword().equals(seller.getPassword())) {
            //密码错误
            throw new RuntimeException("密码错误");
        }
        //查询卖家信息
        return dbSeller;
    }
}
